﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Generator.SectionCodeGenerator
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using Microsoft.Internal.Web.Utils;
using System.Collections;
using System.Web.Razor.Parser.SyntaxTree;

namespace System.Web.Razor.Generator
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents a section code generator.</summary>
  public class SectionCodeGenerator : BlockCodeGenerator
  {
    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Initializes a new instance of the <see cref="T:System.Web.Razor.Generator.SectionCodeGenerator" /> class.</summary>
    /// <param name="sectionName">The name of the section code.</param>
    public SectionCodeGenerator(string sectionName) => this.SectionName = sectionName;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the name of the section.</summary>
    /// <returns>The name of the section.</returns>
    public string SectionName { get; private set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Generates a block before the section code.</summary>
    /// <param name="target">The target to generate.</param>
    /// <param name="context">The code generator context.</param>
    public override void GenerateStartBlockCode(Block target, CodeGeneratorContext context)
    {
      string generatedCode = context.BuildCodeString((Action<CodeWriter>) (cw =>
      {
        cw.WriteStartMethodInvoke(context.Host.GeneratedClassContext.DefineSectionMethodName);
        cw.WriteStringLiteral(this.SectionName);
        cw.WriteParameterSeparator();
        cw.WriteStartLambdaDelegate();
      }));
      context.AddStatement(generatedCode);
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Generates a block after the section code.</summary>
    /// <param name="target">The target to generate.</param>
    /// <param name="context">The code generator context.</param>
    public override void GenerateEndBlockCode(Block target, CodeGeneratorContext context)
    {
      string generatedCode = context.BuildCodeString((Action<CodeWriter>) (cw =>
      {
        cw.WriteEndLambdaDelegate();
        cw.WriteEndMethodInvoke();
        cw.WriteEndStatement();
      }));
      context.AddStatement(generatedCode);
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the specified object is equal to the current object.</summary>
    /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
    /// <param name="obj">The object to compare to.</param>
    public override bool Equals(object obj) => obj is SectionCodeGenerator sectionCodeGenerator && base.Equals((object) sectionCodeGenerator) && string.Equals(this.SectionName, sectionCodeGenerator.SectionName, StringComparison.Ordinal);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Retrieves the hash code for this current instance.</summary>
    /// <returns>The hash code for this current instance.</returns>
    public override int GetHashCode() => HashCodeCombiner.Start().Add(base.GetHashCode()).Add((IEnumerable) this.SectionName).CombinedHash;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns a string representation of this current instance.</summary>
    /// <returns>A string representation of this current instance.</returns>
    public override string ToString() => "Section:" + this.SectionName;
  }
}
